/*	Entry Point http://support.microsoft.com/kb/815065
BOOL APIENTRY DllMain(
HANDLE hModule,	// Handle to DLL module
	DWORD ul_reason_for_call,	// Reason for calling function
	LPVOID lpReserved ) // Reserved
{
	switch ( ul_reason_for_call )
	{
		case DLL_PROCESS_ATTACHED:
		// A process is loading the DLL.
		break;
		case DLL_THREAD_ATTACHED:
		// A process is creating a new thread.
		break;
		case DLL_THREAD_DETACH:
		// A thread exits normally.
		break;
		case DLL_PROCESS_DETACH:
		// A process unloads the DLL.
		break;
	}
	return TRUE;
}*/


#include <string>

#define DllImport   __declspec( dllimport )


class DllImport ColumnDefinition {
		string Name;
		Types Type;
		bool Key;
	public:
		//Constructors:
		ColumnDefinition(string _Name, Types _Type);
		ColumnDefinition(string _Name, Types _Type, bool _Key);
		ColumnDefinition(const ColumnDefinition& CopyCD);
		
		//Accessor Methods:
		string GetName() const;
		Types GetType() const;
		bool GetKey() const;
		string ToString() const;
		
		//Mutator Methods:
		void Rename(string n);
};




/*	From Rev 35
	//Methods
	int InsertByAddr(void* Record);			//1
	int Insert(void *Record, ...);			//2
	int Remove(Predicate *p);				//2					 //1 ready for testing
	int Update(Predicate *p, CD* cd);		//3					 //2 need minor feedback
	Entity* Where(Predicate *p);			//2					 //3 moderate feedback require or moderate work remaining
	int Count(string columnName);			//1					 //4 much work needed
	int Sum(string columnName);				//2					 //5 no work completed
	void* Min(string columnName);			//1
	void* Max(string columnName);			//1
	int RenameColumn(string o, string n);	//1
	string GetName() const;					//1
	string ToMetaString() const;			//1		
	string ToString() const;				//1*/
class DllImport Entity {
		string Name;
	public:
		//Public Data:
		list<void*> Rows;
		list<CD> Columns;

		//Constructors:
		Entity(string _Name, ColumnDefinition _ColumnDefinitions[]);
		Entity(string _Name, list<CD> ColumnDefinitions);
		Entity(const Entity& CopyEntity);
		
		//Accessor Methods:			
		Entity* Where(Predicate *p);		
		int Count(string columnName);		
		int Sum(string columnName);			
		void* Min(string columnName);		
		void* Max(string columnName);		
		string GetName() const;				
		string ToMetaString() const;		
		string ToString() const;

		//Mutator Methods:
		int RenameColumn(string o, string n);
		int InsertByAddr(void* Record);		
		int Insert(void *Record, ...);		
		int Remove(Predicate *p);			
		int Update(Predicate *p, CD* cd);

		//Operator Overloads:
		Entity& operator+= (Entity _Entity);
		bool Entity::operator ==(Entity& _Entity);
};


/*	From Rev 35
	int Create(Entity &entity);							//2
	int Delete(Entity &entity);							//1					//1 ready for testing					
	int ExecuteScalar(string query, Int *result);		//5					//2 need minor feedback		
	int ExecuteScalar(string query, Float *result);		//5					//3 moderate feedback require or moderate work remaining		
	int ExecuteScalar(string query, Date *result);		//5					//4 much work needed
	int ExecuteScalar(string query, Time *result);		//5					//5 no work completed
	int ExecuteScalar(string query, String *result);	//5
	int ExecuteReader(string query, Entity *result);	//1
	int ExecuteNonQuery(string query);					//1
	Entity& operator[] (string _Name);					//1
	Entity& operator[] (string _Names[]);				//3
	string ToString() const;							//1
	DBContext(string _Name);							//1*/
class DllImport DBContext {
		list<Entity> Entities;
		string Name;
	public:
		//Constructors:
		DBContext(string _Name);
		DBContext(char* _Name);
		//Accessor Methods:
		int ExecuteReader(string query, Entity *result);
		int ExecuteNonQuery(string query);	

		//Mutator Methods:
		int Create(Entity &entity);						
		int Delete(Entity &entity);						
		int ExecuteScalar(string query, Int *result);	
		int ExecuteScalar(string query, Float *result);	
		int ExecuteScalar(string query, Date *result);	
		int ExecuteScalar(string query, Time *result);	
		int ExecuteScalar(string query, String *result);
					
		//Operator Overloads:
		Entity& operator[] (string _Name);				
		Entity& operator[] (string _Names[]);			
		string ToString() const;						
};


